package com.zsp.coupon.advice;


import com.zsp.coupon.exception.CouponException;
import com.zsp.coupon.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * 全局异常处理
 */
@RestControllerAdvice
public class GloableException {

    //对couponexception进行统一的处理
    @ExceptionHandler(value = CouponException.class)
    public CommonResponse<String> handlerCouponException(
            HttpServletRequest request, CouponException ce){
        CommonResponse<String> response=new CommonResponse<>(
                -1,"buinesss error"
        );
        response.setData(ce.getMessage());
        return  response;
    }
}
